#ifndef _RAND_GEN_H_
#define _RAND_GEN_H_

#include <set>
#include "LADSUtil/RandGen.h"

namespace LADSUtil {

class RandGen {

    public: 

        virtual ~RandGen() {}

        // random int between 0 and max rand number.
        virtual int randint()=0;

        //random float in [0,1]
        virtual float randfloat(); 

        //random double in [0,1]
        virtual double randdouble();
  
        //random double in [0,1)
        virtual double randDoubleOneExcluded();

        //random int in [0,n)
        virtual int randint(int n);

        // return -1 or 1 randonly
        virtual int randPositiveNegative();

        // Random int from a gaussian distribution. Neg numbers are clipped to 0
        virtual unsigned int pos_gaussian_rand(unsigned int std_dev, unsigned int mean);

        //random boolean
        virtual bool randbool();

};

    //choose uniformly randomly an element of the set s
    //WARNING : it is assumed that s is non-empty
    template<typename T> T randset(const std::set<T>& s, RandGen& rng) {
        cassert(TRACE_INFO, !s.empty(), "numeric - std::set should be empty.");
        int chosen_int = rng.randint(s.size());
        typename std::set<T>::const_iterator s_it = s.begin();
        //can be optimized maybe
        for(int si = 0; si < chosen_int; si++) 
          ++s_it;
        return *s_it;
    }

}

#endif /* _RAND_GEN_H_ */
